package JDBC.model;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Fou Jack of all trades and master of none.
 * @date 2022/1/6 17:35
 */
public class SpringTransaction {
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"Transaction.xml"});
        BeanFactory factory = context;
        IUserDAO userDAO = (IUserDAO) factory.getBean("userDaoProxy");
        try{
            userDAO.transfer(2,3,100);
            System.out.println("转账成功~~");
        }catch (Exception e){
            System.out.println("事务回滚！");

        }
    }
}
